/**
 * ===========================================================================
 * 版权所有 湖南免了么网络科技有限公司，并保留所有权利。
 * 网站地址: http://www.mianle.me
 * ===========================================================================
 * 15:58 2018/6/5
 */
package com.mianle.userapi.config;

import io.rong.RongCloud;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.boot.context.properties.EnableConfigurationProperties;
import org.springframework.context.annotation.Bean;
import org.springframework.context.annotation.Configuration;

/**
 * @Author: yiyuan
 * @Description:
 * @Date: Created in 15:58 2018/6/5
 *
 */
@Configuration
@EnableConfigurationProperties(RongCloudProperties.class)
public class RongCloudAutoConfiguration {

    @Autowired
    private RongCloudProperties rongCloudProperties;

    @Bean
    public RongCloud rongCloud() {
        if(rongCloudProperties.getAppKey() == null || rongCloudProperties.getAppSecret() == null) {
            return null;
        }
        return RongCloud.getInstance(rongCloudProperties.getAppKey(), rongCloudProperties.getAppSecret());
    }
}
